package models

import (
	"log"
	"os"

	"github.com/go-xorm/xorm"
	_ "github.com/mattn/go-sqlite3"
)

var Engine *xorm.Engine

func init() {
	_, err := os.Open("face.db")
	if err != nil {
		os.Create("face.db")
	}

	Engine, err = xorm.NewEngine("sqlite3", "face.db")
	if err != nil {
		log.Println(err)
	}

	// 初始化数据表
	if _, err := Engine.Exec(PERSON); err != nil {
		log.Panic(err)
	}

	if _, err := Engine.Exec(FACE); err != nil {
		log.Panic(err)
	}

}
